From 02f96b4a0632d3fda201a9e0fcf66ee0d7696c64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A1=D1=83=D1=85=D0=B0=D1=80=D0=B8=D0=BA?= Date: Wed, 3 Sep 2014 19:09:05 +0400 Subject: [PATCH] cargo/new: add `--travis` flag --- src/bin/new.rs | 4 +++- src/cargo/ops/cargo_new.rs | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/new.rs b/src/bin/new.rs index a1e72c1bd..bac9739a7 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -15,6 +15,7 @@ Usage: Options: -h, --help Print this message --git Initialize a new git repository with a .gitignore + --travis Create a .travis.yml file --bin Use a binary instead of a library template -v, --verbose Use verbose output ") @@ -23,10 +24,11 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult debug!("executing; cmd=cargo-new; args={}", os::args()); shell.set_verbose(options.flag_verbose); - let Options { flag_git, flag_bin, arg_path, .. } = options; + let Options { flag_git, flag_travis, flag_bin, arg_path, .. } = options; let opts = ops::NewOptions { git: flag_git, + travis: flag_travis, path: arg_path.as_slice(), bin: flag_bin, }; diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 9ff86e79b..42b631c92 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -8,6 +8,7 @@ use core::shell::MultiShell; pub struct NewOptions<'a> { pub git: bool, + pub travis: bool, pub bin: bool, pub path: &'a str, } @@ -38,6 +39,10 @@ fn mk(path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> { try!(fs::mkdir(path, io::UserRWX)); } + if opts.travis { + try!(File::create(&path.join(".travis.yml")).write_str("language: rust\n")); + } + let author = try!(discover_author()); try!(File::create(&path.join("Cargo.toml")).write_str(format!( r#"[package] -- 2.30.2